//
//  ZCSRecommendTVC.m
//  聆听FM
//
//  Created by dllo on 16/6/7.
//  Copyright © 2016年 Dark. All rights reserved.
//

#import "ZCSRecommendTVC.h"
#import "ZCSEditorReListModel.h"
#import "ZCSHotRecomListListModel.h"
#import "LTAlbumModel.h"
@implementation ZCSRecommendTVC

- (void)awakeFromNib {
    [super awakeFromNib];
    self.leftImageView.tag = 1000;
    self.midImageView.tag = 1001;
    self.rightImageView.tag = 1002;
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushAlbumVC:)];
    UITapGestureRecognizer *midTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushAlbumVC:)];
    UITapGestureRecognizer *rightTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushAlbumVC:)];
    [self.leftImageView addGestureRecognizer:tap];
    [self.midImageView addGestureRecognizer:midTap];
    [self.rightImageView addGestureRecognizer:rightTap];
    self.backgroundColor = [UIColor colorWithWhite:1 alpha:0.2];

}
- (LTAlbumModel *)ModelWith:(id)Model
{
    ZCSEditorReListModel *leftModel = (ZCSEditorReListModel *)Model;
    LTAlbumModel *model = [[LTAlbumModel alloc] init];
    model.albumId = leftModel.albumId;
    model.playsCounts = leftModel.playsCounts;
    model.albumCoverUrl290 = leftModel.albumCoverUrl290;
    model.tracks = leftModel.tracks;
    model.title = leftModel.title;
    model.intro = leftModel.intro;
    return model;
}

- (LTAlbumModel *)hotModelWith:(ZCSHotRecomListListModel *)leftModel
{
    LTAlbumModel *model = [[LTAlbumModel alloc] init];
    model.albumId = leftModel.albumId;
    model.playsCounts = leftModel.playsCounts;
    model.albumCoverUrl290 = leftModel.albumCoverUrl290;
    model.tracks = leftModel.tracks;
    model.title = leftModel.title;
    model.intro = leftModel.intro;
    return model;
}

- (void)pushAlbumVC:(UITapGestureRecognizer *)tap
{
    NSInteger tag = tap.view.tag - 1000;
    switch (tag) {
        case 0:
        {
            if (_editorModel) {
                ZCSEditorReListModel *leftModel = _editorModel.list[0];
                

                self.rBlock([self ModelWith:leftModel]);
            }
            else
            {
               ZCSHotRecomListListModel *leftModel = _hotRecomListModel.list[0];
                
                self.rBlock([self hotModelWith:leftModel]);
            }
        }
            break;
        case 1:
        {
            if (_editorModel) {
                ZCSEditorReListModel *leftModel = _editorModel.list[1];
                self.rBlock([self ModelWith:leftModel]);
            }
            else
            {
                ZCSHotRecomListListModel *leftModel = _hotRecomListModel.list[1];
                self.rBlock([self hotModelWith:leftModel]);
            }
        }
            break;
        case 2:
        {
            if (_editorModel) {
                ZCSEditorReListModel *leftModel = _editorModel.list[2];
                self.rBlock([self ModelWith:leftModel]);
            }
            else
            {
                ZCSHotRecomListListModel *leftModel = _hotRecomListModel.list[2];
                self.rBlock([self hotModelWith:leftModel]);
            }
        }
            break;
        default:
            break;
    }
}


- (void)setEditorModel:(ZCSEditorRecomModel *)editorModel
{
    if (_editorModel != editorModel) {
        _editorModel = editorModel;
         NSString *tempString = @"           ";
        //左图
        ZCSEditorReListModel *leftModel = editorModel.list[0];
        [self.leftImageView sd_setImageWithURL:[NSURL URLWithString:leftModel.albumCoverUrl290] placeholderImage:[UIImage sd_animatedGIFNamed:@"占位图"]];

        self.leftConLabel.text = [leftModel.intro stringByAppendingString:tempString];
        self.leftNameLabel.text = leftModel.title;
        
        //中图
        
        ZCSEditorReListModel *midModel = editorModel.list[1];
        [self.midImageView sd_setImageWithURL:[NSURL URLWithString:midModel.albumCoverUrl290] placeholderImage:[UIImage sd_animatedGIFNamed:@"占位图"]];
        self.midConLabel.text = [midModel.intro stringByAppendingString:tempString];
        self.midNameLabel.text = midModel.title;
        
        
        //右图
        
        ZCSEditorReListModel *rightModel = editorModel.list[2];
        [self.rightImageView sd_setImageWithURL:[NSURL URLWithString:rightModel.albumCoverUrl290] placeholderImage:[UIImage sd_animatedGIFNamed:@"占位图"]];
        self.rightConLabel.text = [rightModel.intro stringByAppendingString:tempString];
        self.rightNameLabel.text = rightModel.title;
        
    }
}

- (void)setHotRecomListModel:(ZCSHotRecomListModel *)hotRecomListModel
{
    if (_hotRecomListModel != hotRecomListModel) {
        _hotRecomListModel = hotRecomListModel;
         NSString *tempString = @"                 ";
        //左图
        ZCSHotRecomListListModel *leftModel = hotRecomListModel.list[0];
        [self.leftImageView sd_setImageWithURL:[NSURL URLWithString:leftModel.albumCoverUrl290] placeholderImage:[UIImage sd_animatedGIFNamed:@"占位图"]];
        self.leftConLabel.text = [leftModel.intro stringByAppendingString:tempString];
        self.leftNameLabel.text = leftModel.title;
        //中图
        ZCSHotRecomListListModel *midModel = hotRecomListModel.list[1];
        [self.midImageView sd_setImageWithURL:[NSURL URLWithString:midModel.albumCoverUrl290] placeholderImage:[UIImage sd_animatedGIFNamed:@"占位图"]];
        self.midConLabel.text = [midModel.intro stringByAppendingString:tempString];
        self.midNameLabel.text = midModel.title;
        //右图
        ZCSHotRecomListListModel *rightModel = hotRecomListModel.list[2];
        [self.rightImageView sd_setImageWithURL:[NSURL URLWithString:rightModel.albumCoverUrl290] placeholderImage:[UIImage sd_animatedGIFNamed:@"占位图"]];
        self.rightConLabel.text = [rightModel.intro stringByAppendingString:tempString];
        self.rightNameLabel.text = rightModel.title;
        
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
